﻿using System.Globalization;
using System.Reflection;
using System.Resources;

namespace CapstoneProjectAEReader.Common.Utility
{
    public class ResourceReader
    {
        /// <summary>
        /// Resouces manager that contains defined message code and defined message.
        /// </summary>
        private static readonly ResourceManager Manager = new ResourceManager(
            Constants.ApplicationResource, Assembly.GetExecutingAssembly(), null);

        private static CultureInfo _cultureInfo;

        /// <summary>
        /// Prevents a default instance of the ResourceReader class from being created.
        /// </summary>
        private ResourceReader()
        {
        }

        /// <summary>
        /// Initialize with specific language
        /// </summary>
        /// <param name="cultureName"></param>
        public static void Initialize(string cultureName)
        {
            _cultureInfo = new CultureInfo(cultureName);
        }

        /// <summary> 
        /// Return resource content
        /// </summary> 
        /// <param name="code">Code Name</param>        
        /// <returns>Resource Content</returns> 
        /// <remarks></remarks> 
        public static string GetResourceContent(string code)
        {
            return Manager.GetString(code, _cultureInfo);
        }
    }
}
